#

| Chapter 30 vi Tips and Tricks |

## 30.25 vi -r May not Write Recovered Buffer When You Exit

Usually, when you're editing a file with vi, if you type the command ZZ, it saves your file. But, on some versions of vi, if you recover a file with vi -r (30.24), typing ZZ may not save your edits!

That might be a good thing. When you recover a buffer, you need to decide whether the recovered buffer is really what you want. Maybe you've made other changes to the file since then. Maybe something went wrong as the buffer was being saved (say, the system crashed). You shouldn't just save without checking first.

You can use the `:w!` command to write the recovered version after you're sure that you want it. Use the `:q!` command if you don't want the recovered version.

- JP

30.24 vi/ex File Recovery vs. Networked Filesystems |  | 30.26 Shell Escapes: Running One UNIX Command While Using Another